<script>
	$(document).ready(function(){
	
		$("#btn_save").click(function(){
			if($("#KtconfigurationName").attr("value").search(" ")>-1) 
			{
				$("#dflt_dialog").text("<? echo __('El nombre no puede contener espacios en blanco.'); ?>").dialog("open"); 
				return 0;
			}	
			
			if($("#work_folder_mod").attr("value")==1)		work_folder_exist();
			else											$("#KtconfigurationEditForm").submit();
			
		})		

		$("#KtconfigurationDirectory").change(function(){ $("#work_folder_mod").attr("value",1); });	

	
		function work_folder_exist()
		{
			var parametros ="&dir="+($("#KtconfigurationDirectory").attr("value"));
			$.ajax
			({
				type: "post",
				url:"<?php echo $this->base ?>/ktconfigurations/work_folder_exist",
					data:parametros,
					beforeSend: function()
					{
						
					},			
					success: function(datos)
					{
						if(datos=="true")
						{
							$("#dflt_dialog").dialog('option', 'buttons', { "Sobrescribir": function() { $(this).dialog("close"); $("#KtconfigurationEditForm").submit(); },"Cancelar": function() { $(this).dialog("close"); } });
							$("#dflt_dialog").text("<? echo __('El nombre del directorio ya existe. Desea Sobreescribirlo?. Esta operacion no se puede deshacer.'); ?>").dialog("open");
						}
						else
							$("#KtconfigurationEditForm").submit();
					}
				})	
		}
		
		
	});


</script>
<div class="kt-g1">
		<?php echo $form->input('work_folder_mod', array('type'=>'hidden','value'=>0));?> 

		<div class=" kt-right">
	   		<ul class="lst-tabs">
	   			    <li id="icon-edit" class="active"> <span class="icon"></span> <?php echo __('configurations_edit');?> </li>	
	   		   		<li id="icon-new"> <span class="icon"></span> <?php echo $html->link(__('configurations_new',true),$ruta_admin.'/add');?> </li>	    				
	    			<li id="icon-configuration"> <span class="icon"></span> <?php echo $html->link(__('configurations_list',true),$ruta_admin.'/');?> </li>	    				
			</ul>	  
		</div>
</div>
<div class="kt-md kt-md-content">	
		<div class="hd">
			  <h2><?php echo __('configurations_edit');?></h2>	
		</div>
		<div class="bd">	  
			<div class="lst-form">	
			<?php 
				echo $form->create('Ktconfiguration', array('action' => 'edit'));
			?>	
			<table>			
			<tr class="form-field"> 
				 <td>
				 	<p><?php echo $form->input('name',array('class'=>'required'));?> </p>
				</td>	
				 <td>
					<p><?php echo $form->input('directory',array('class'=>'required'));?> </p>
				</td>
				 	
			</tr>
			<tr class="form-field"> 
				 <td>
					<p><?php echo $form->input('hosts',array('class'=>'required'));?> </p>
				</td>
				 <td>
					 <p><?php echo $form->input('database',array('class'=>'required'));?> </p>
				 </td>		
			</tr>
			
			<tr class="form-field"> 
				 <td>
					<p><?php echo $form->input('login',array('class'=>'required'));?> </p>
				</td>
				 <td>
					 <p><?php echo $form->input('password');?> </p>
				 </td>		
			</tr>
			<tr class="form-field"> 
				 <td>
					<p><?php echo $form->input('url', array('label' => __('url - http:// ',true),'class'=>'required'));?> </p>
				</td>
			</tr>
			</table>
			<p class="submit">
				<?php echo $form->input('id', array('type'=>'hidden'));?> 
			  	<?php echo $form->button(__('save',true),array("id"=>"btn_save")); ?>
			</p>
			  <?php echo $form->end();?>  
			</div>
		</div>
	<div class="ft">	
		<p>	<?php echo $html->link(__('configurations_create_new',true), $ruta_admin."add/");?> - <?php echo $html->link(__('comeback',true), $ruta_admin); ?></p>
	</div>	
</div>
	 